package servlets;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import view.MyServer;

import commands.AddUserCommand;


/**
 * StopServerServlet implementation class ServerServlet - stop the server
 * answer urls: .../StopServerServlet
 */
public class StopServerServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * constructor
     * @see HttpServlet#HttpServlet()
     */
    public StopServerServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * stop the server
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		response.setContentType("text/html");
        response.setStatus(HttpServletResponse.SC_OK);
        
        MyServer.stop();
        System.out.println("stop server");
        
	}

	/**
	 * do nothing
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
